package com.sc.servlet.admin.field;

import com.alibaba.fastjson.JSONObject;
import com.sc.services.FieldServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * @description: 通过id单个删除
 * @author: sc
 * @create: 2023-01-03 21:58
 **/
@WebServlet("/deleteById")
public class deleteByIdServlet extends HttpServlet {

    private FieldServices fieldServices = new FieldServices();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String fieldid = request.getParameter("fieldid");
        String res=null;

        fieldServices.deleteFieldById(Integer.parseInt(fieldid));
        res = "delete_suc";

        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(res);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}